package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ChatContent;
import com.ruoyi.system.service.IChatContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 聊天信息管理Controller
 * 
 * @author ruoyi
 * @date 2024-01-04
 */
@RestController
@RequestMapping("/system/chat_content")
public class ChatContentController extends BaseController
{
    @Autowired
    private IChatContentService chatContentService;

    /**
     * 查询聊天信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:chat_content:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChatContent chatContent)
    {
        startPage();
        List<ChatContent> list = chatContentService.selectChatContentList(chatContent);
        return getDataTable(list);
    }

    /**
     * 导出聊天信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:chat_content:export')")
    @Log(title = "聊天信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChatContent chatContent)
    {
        List<ChatContent> list = chatContentService.selectChatContentList(chatContent);
        ExcelUtil<ChatContent> util = new ExcelUtil<ChatContent>(ChatContent.class);
        util.exportExcel(response, list, "聊天信息管理数据");
    }

    /**
     * 获取聊天信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:chat_content:query')")
    @GetMapping(value = "/{chatId}")
    public AjaxResult getInfo(@PathVariable("chatId") Long chatId)
    {
        return success(chatContentService.selectChatContentByChatId(chatId));
    }

    /**
     * 新增聊天信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:chat_content:add')")
    @Log(title = "聊天信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChatContent chatContent)
    {
        return toAjax(chatContentService.insertChatContent(chatContent));
    }

    /**
     * 修改聊天信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:chat_content:edit')")
    @Log(title = "聊天信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChatContent chatContent)
    {
        return toAjax(chatContentService.updateChatContent(chatContent));
    }

    /**
     * 删除聊天信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:chat_content:remove')")
    @Log(title = "聊天信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chatIds}")
    public AjaxResult remove(@PathVariable Long[] chatIds)
    {
        return toAjax(chatContentService.deleteChatContentByChatIds(chatIds));
    }
}
